const app = getApp()
import { getSystemConfig, getAppid } from './config.js'
/**
 * 获取连接中是否有此参数
 * @param {Object} name
 */
const getUrlCode = (name) => {
	return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)')
		.exec(location.href) || [, ''])[1]
	.replace(/\+/g, '%20')) || null
}
/**
 * // 根据openid判断是否去授权
 */
const ifAuthed = () => {
	let openidcode = uni.getStorageSync('openid') ? uni.getStorageSync('openid') : ''
	let token = uni.getStorageSync('token') ? uni.getStorageSync('token') : ''
	if (openidcode.trim()) {
		return true;
	} else {
		return false;
	}
}
/**
 * 跳转到授权页面
 */
const filterDo = () => {
	const authhttp_dev = 'http://jdb.lx.58qf.com/WxCenter/Main/getUserInfo/lx_wlp_lt_login_local?appid=' + getAppid();

	window.location.href = process.env.NODE_ENV === 'development' ? authhttp_dev :
		getSystemConfig().login
}
module.exports = {
	baseUrl: getSystemConfig().baseUrl,
	shareUrl: getSystemConfig().shareUrl,
	appid: getAppid(),
	getUrlCode,
	filterDo,
	ifAuthed,
	serveConfig: getSystemConfig()
}